package com.ubi.core.framework.validation;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.List;

public class SafeStringListValidator implements ConstraintValidator<SafeString, List<String>> {

    @Override
    public void initialize(SafeString safeString) {
    }

    @Override
    public boolean isValid(List<String> values, ConstraintValidatorContext context) {
        if (null == values) {
            return true;
        }

        for (String value : values) {
            if (!SafeStringValidateUtils.validate(value))
                return false;
        }
        return true;
    }
}
